const app = getApp()

Page({
  data: {
    motto: 'Hello World',
    itemlist: [
      {
        logo: "/images/translate.png",
        title: "翻译",
        desc: "支持中英法等语种翻译",
        url: "../translate/translate"
      },
      {
        logo: "/images/calculate.png",
        title: "计算器",
        desc: "满足日常所需的计算器",
        url: "../cal/cal"
      },
      {
        logo: "/images/weather.png",
        title: "天气",
        desc: "显示Hello World",
        url: "../weather/weather"
      },
      {
        logo: "/images/calendar.png",
        title: "日历",
        desc: "显示日历、年历",
        url: "../calendar/calendar"
      },
      {
        logo: "/images/metro.png",
        title: "地铁站",
        desc: "显示日常Kettle程序运行情况",
        url: "../metro/metro"
      },
      {
        logo: "/images/system.png",
        title: "本机信息",
        desc: "显示本机型号，wifi等系统信息",
        url: "../system/system"
        },
        {
            logo: "/images/healthy.png",
            title: "贴身管家",
            desc: "显示用户BMI指数",
            url: "../healthy/healthy"
        },
        {
            logo: "/images/healthy.png",
            title: "车价查询",
            desc: "查询车辆指导价",
            url: "../autohome/autohome"
        },        
    ],
    paymodalHidden: true,
    isPopping: true,      //右下角是否已经弹出
  }, 
  onLoad: function () {
    
  },
  plus: function () {   //右下角点击弹出
    if (this.data.isPopping) {
      //缩回动画
      this.takeback()
      setTimeout(() => {
        this.setData({
          isPopping: false,
          is_hidden: true
        })
      }, 500)
    } else if (!this.data.isPopping) {
      //弹出动画
      this.setData({
        isPopping: true,
        is_hidden: false
      })
      this.popp()
    }
  },
  popp: function () {   //弹出动画
    //plus顺时针旋转
    var animationPlus = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    var animationWxservice = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    animationPlus.rotateZ(90).step();       //PLUS旋转90°
    animationWxservice.opacity(1).step()    //item逐渐显示
    this.setData({
      animPlus: animationPlus.export(),
      animWxservice: animationWxservice.export(),
    })
  },
  takeback: function () {   //收回动画
    //plus逆时针旋转

    var animationPlus = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    var animationWxservice = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease-out'
    })
    animationPlus.rotateZ(0).step()
    animationWxservice.translate(0, 0).rotateZ(0).opacity(0).step()
    this.setData({
      animPlus: animationPlus.export(),
      animWxservice: animationWxservice.export(),
    })
  },
  show_pay_modal: function () {   //点击显示支付模态框
    this.setData({
      paymodalHidden: false
    })
  },
  paymodalCancel: function () {   //模态框点击取消
    this.setData({
      paymodalHidden: true
    })
  },
  paymodalConfirm: function () {    //模态框点击确认
    this.setData({
      paymodalHidden: true
    })
  },
  previewpayImage: function (e) {   //点击赞赏图片浏览保存
    var current = e.target.dataset.src;
    wx.previewImage({
      current: current,     // 当前显示图片的http链接
      urls: ['https://gss0.baidu.com/-Po3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/43a7d933c895d143fee15a247ef082025aaf0725.jpg'] // 需要预览的图片http链接列表
    })
  },
  onShareAppMessage: function () { //用户点击右上角分享   
    return {
      title: '篮子数据分享', // 分享标题
      desc: '篮子数据分享', // 分享描述
      path: 'pages/itemlist/itemlist' // 分享路径
    }
  },
})